<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <meta http-equiv="content-type" content="text/html; charset=utf-8">
    <meta http-equiv="content-language" content="zh-CN">
    <meta content="1 days" name="revisit-after" />
    <meta name="robots" content="all">
    <meta name="viewport" content="width=750, maximum-scale=1.0, user-scalable=no">
    <meta content="yes" name="apple-mobile-web-app-capable" />
    <meta content="black" name="apple-mobile-web-app-status-bar-style" />
    <meta content="telephone=no" name="format-detection" />
    <meta content="false" id="twcClient" name="twcClient" />
    <link rel="stylesheet" href="css/swiper.min.css">
    <link rel="stylesheet" href="css/reset.css">
    <link rel="stylesheet" href="css/intergral.css">
    <script src="js/common.js"></script>
    <script type="text/javascript" src="https://res.wx.qq.com/open/js/jweixin-1.3.2.js"></script>
    <script src="https://cdn.jsdelivr.net/npm/vue"></script>
    <script src="js/swiper.min.js"></script>
    <script src="https://unpkg.com/axios/dist/axios.min.js"></script>
    <title>亮度</title>
</head>

<body>
    <div class="intergral" id="intergral">
        <header>
            <p>我的亮度</p>
            <p class="num">{{inter.credit}}</p>
        </header>
        <main>
            <ul class="list">
                <li v-for="item in inter.items">
                    <div class="left">
                        <div class="row1">{{item.remark}}</div>
                        <div class="row2">{{item.create_at}}</div>
                    </div>
                    <div  v-if="item.type == 1" class="add right">
                        <span v-if="item.type == 1">+</span>{{item.amount}}
                    </div>
                    <div  v-if="item.type == 2" class="right">
                        <span v-if="item.type == 2">-</span>{{item.amount}}
                    </div>
                </li>
            </ul>
            <p class="noCride" v-if="inter.items.length == 0 ">您暂时还没有“亮度值”哦</p>
        </main>
    </div>
</body>

</html>
<script>
    var app4 = new Vue({
        el: '#intergral',
        data() {
            return {
                SetFun: '',
                access_token: '',
                inter: ''
            };
        },
        methods: {
            reload(){
                location.href ="intergral.html";
            },
            getInter() {
                var _self = this;
                var access_token = localStorage.getItem('access_token');
                this.access_token = access_token;
                if (access_token) {
                    axios.get("http://airen.2020-2020.com/v1/users/credits?access_token=" + access_token)
                        .then(function (res) {
                            var res = res.data.data;
                            res.credit = _self.toThousands(res.credit);
                            _self.inter = res;
                        })
                        .catch(function (err){
                            var status = err.toString().replace(/[^0-9]/ig, "");
                            if (status == 402) {
                                _self.SetFun.isCode(_self.reload);
                            }
                        })
                } else {
                    _self.SetFun.isCode(_self.reload);
                }
            },
            toThousands(num) {  
                return (num || 0).toString().replace(/(\d)(?=(?:\d{3})+$)/g, '$1,');  
            } 
        },
        created() {
        },
        mounted() {
            var _self = this;
            _self.SetFun = new window.SetFun();
            this.getInter();
            _self.SetFun.hideMenu();
        },
    })
</script>